package org.millioncall.yueyoga.admin.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.millioncall.openplatform.common.PaginatedList;
import org.millioncall.yueyoga.admin.dao.CoachDAO;
import org.millioncall.yueyoga.admin.model.Coach;
import org.millioncall.yueyoga.admin.service.CoachService;
import org.springframework.stereotype.Service;

@Service
public class CoachServiceImpl implements CoachService {
	private static final Logger logger = LoggerFactory.getLogger(Coach.class);
	private CoachDAO coachDAO;

	public CoachDAO getCoachDAO() {
		return coachDAO;
	}

	public void setCoachDAO(CoachDAO coachDAO) {
		this.coachDAO = coachDAO;
	}

	@Override
	public PaginatedList<Coach> getCoachInPage(int start, int pageSize) {
		PaginatedList<Coach> p = coachDAO.findPage(start, pageSize);
		return p;
	}

	@Override
	public void deleteCoachByIds(Integer[] deids) {
		if (deids == null || deids.length == 0) {
			logger.error("未提交要删除演讲者的编号");
			throw new RuntimeException(" 未提交要删除演讲者的编号");
		} else {
			this.coachDAO.deleteByIds(deids);
		}
	}

	@Override
	public boolean saveCoach(Map<String, Object> map) {
		return coachDAO.save(map) > 0;
	}

	@Override
	public boolean updateCoach(Map<String, Object> map) {
		int i = coachDAO.update(map);
		if (i > 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public PaginatedList<Coach> getCoachInPage(int start, int pageSize,
			Map<String, Object> map) {
		PaginatedList<Coach> p = coachDAO.findPage(start, pageSize, map);
		return p;
	}

	@Override
	public List<Coach> findAll(Map<String, Object> map) {
		return this.coachDAO.findAll(map);
	}

	@Override
	public Coach findById(Integer id) {
		return this.coachDAO.findById(id);
	}

	@Override
	public List<Coach> findCoach0() {
		return this.coachDAO.findCoach0();
	}

	@Override
	public List<Coach> findCoach1() {
		return this.coachDAO.findCoach1();
	}

	@Override
	public List<Coach> findAllTeacherByOrganizationId(Map<String, Object> map) {
		return this.coachDAO.findAllTeacherByOrganizationId(map);
	}

	@Override
	public List<Coach> findAllAssistantByOrganizationId(Map<String, Object> map) {
		return this.coachDAO.findAllAssistantByOrganizationId(map);
	}
}
